<?php

class article{
	
	private $db;
	private $article;
	
	function __construct($url){
		try {
	
			$this->db = pg_connect("host='".DB_HOST."' dbname='".DB_NAME."' user='".DB_USER."' password='".DB_PASS."'");
		}catch (Exception $e){
			echo $e->getMessage();
		}
	
		$this->setArticle($url);
	
		return 0;
	}
	
	function setArticle($url){
		try {
			$query = "Select *
				from articles
				where url = '".$url."'";
			$result = pg_query($this->db,$query);
			$row = pg_fetch_all($result);
	
		}catch (Exception $e){
			echo $e->getMessage();
		}
	
		$this->article=$row;

		return 0;
	}
	
	function getArticle(){
		return $this->article;
	}
}
?>